package org.example.im.common.codec;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import lombok.RequiredArgsConstructor;
import org.example.im.bean.protocol.Packet;
import org.springframework.stereotype.Component;

/**
 * @author dingrui
 * @since 2022/2/11
 * @description 编码
 */
@Deprecated
@Component
@RequiredArgsConstructor
public class PacketEncoder extends MessageToByteEncoder<Packet> {

    private final PacketCodec packetCodec;

    @Override
    protected void encode(ChannelHandlerContext channelHandlerContext, Packet packet, ByteBuf byteBuf) throws Exception {
        this.packetCodec.encode(packet, byteBuf);
    }
}
